package org.chronologger.poppaea.client.widgets;

import org.chronologger.poppaea.client.domain.Person;
import org.chronologger.poppaea.client.domain.Scene;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;

public class PersonButtonWidget extends SegmentedButton {

	private final Person person;
	private final Scene scene;
	
	protected void removePersonFromScene() {
		scene.removePerson(person);
		removeFromParent();
	}
	
	public PersonButtonWidget(Scene scene, Person person) {
		super();
		this.person = person;
		this.scene = scene;
		addSegment(this.person.getName());

		addSegment("&#215;", true).addClickHandler(new ClickHandler() {
			
			public void onClick(ClickEvent event) {
				removePersonFromScene();
			}
		});
	}
	
}
